Ninja Database Pro
Using LinqPad
Basic Tasks > Using LinqPad

 

Go into the query properties.

Add these references:

·         KellermanSoftware.Serialization.dll

·         KellermanSoftware.Ninja-Database-Pro.dll

·         A reference to your business entities.  In this case, our entities are in the Ninja-Database-Pro-Tests.dll

 

Add the namespaces that will be used as shown below.

 

Click Ok

Add a query to the query window:

 

void Main()

{

       NinjaDbPro ninja = new NinjaDbPro("myTestDir","myTestDb");

       ninja.Storage = new MemoryDatabase();

      

       ninja.OpenDatabase();

 

       Order order = new Order();

       order.Buyer = new Person();

       order.Buyer.Name = "John Doe";

       order.Buyer.DateCreated = DateTime.Now;

       order.OrderDetails = new List<OrderDetail>();

 

       OrderDetail detail1 = new OrderDetail();

       detail1.Item = new Product();

       detail1.Item.Name = "Wizard";

       detail1.Item.Cost = 29.98M;

       detail1.Quantity = 2;

       detail1.Order = order;

       order.OrderDetails.Add(detail1);

 

       OrderDetail detail2 = new OrderDetail();

       detail2.Item = new Product();

       detail2.Item.Name = ".NET Caching Library";

       detail2.Item.Cost = 199.95M;

       detail2.Quantity = 1;

       detail2.Order = order;

       order.OrderDetails.Add(detail2);

 

       ninja.Save(order);

 

       ObjectQuery<Order> query = ninja.CreateObjectQuery<Order>();

 

       var result = from o in query

                            where o.Buyer.Name == "John Doe"

                            select o;

      

       result.Dump();      

      

       ninja.CloseDatabase();

}